# Load necessary packages
pacman::p_load(tidyverse, knitr, here, plotly)
# Import the non-communicable diseases data
data_ncd <- read_csv(here("data/burden-of-disease-ncd.csv"))
## Rows: 8010 Columns: 4
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (2): Entity, Code
## dbl (2): Year, DALYs (Disability-Adjusted Life Years) - Non-communicable dis...
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
# Filter the dataset to include only the three countries chosen by your group.
data_ncd_mini <- data_ncd %>%
filter(Entity %in% c("Botswana", "Brazil", "Brunei"))
# convert column names to lower cases
names(data_ncd_mini) <- tolower(make.names(names(data_ncd_mini)))
#rename daly
data_ncd_mini <- data_ncd_mini %>%
rename(
daly = dalys..disability.adjusted.life.years....non.communicable.diseases...sex..both...age..age.standardized..rate.
)
# rename entity to country
data_ncd_mini <- data_ncd_mini %>%
rename(
country = entity
)
# Here render a table for the DALY burden over time for the three countries.
# You should pivot the data wider to show each country in a separate column.
# Pivot to wide format, keeping country and code as identifiers
data_ncd_wide <- data_ncd_mini %>%
pivot_wider(
id_cols = c(country, code),
names_from = year,
values_from= daly
)
# Render the wide table using kable()
knitr::kable(
data_ncd_wide,
caption = "DALYs by Country and Year",
digits = 2,
align = c("l", "l", rep("r", ncol(data_ncd_wide) - 2))
)
| country | code | 1990 | 1991 | 1992 | 1993 | 1994 | 1995 | 1996 | 1997 | 1998 | 1999 | 2000 | 2001 | 2002 | 2003 | 2004 | 2005 | 2006 | 2007 | 2008 | 2009 | 2010 | 2011 | 2012 | 2013 | 2014 | 2015 | 2016 | 2017 | 2018 | 2019 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Botswana | BWA | 26190.62 | 26509.04 | 27015.22 | 27528.12 | 28218.32 | 28895.38 | 29361.37 | 29736.86 | 30315.12 | 30743.29 | 31281.86 | 31559.43 | 31665.12 | 31268.71 | 30380.28 | 29328.62 | 28672.05 | 27904.02 | 27746.63 | 27480.15 | 27403.35 | 27281.79 | 27011.70 | 26801.49 | 26616.81 | 26407.15 | 26063.55 | 25947.89 | 25835.51 | 25671.73 |
| Brazil | BRA | 26878.18 | 26274.16 | 25980.82 | 25987.45 | 25642.50 | 25320.93 | 25135.56 | 24790.31 | 24678.36 | 24505.38 | 24259.14 | 24054.18 | 23876.85 | 23726.83 | 23577.01 | 23171.79 | 22954.68 | 22684.44 | 22432.92 | 22202.47 | 22005.03 | 21845.06 | 21549.33 | 21327.61 | 21068.12 | 20914.63 | 20920.49 | 20629.32 | 20465.81 | 20309.17 |
| Brunei | BRN | 29769.74 | 29192.58 | 28694.22 | 28181.41 | 27201.24 | 26569.97 | 25848.91 | 25972.17 | 25911.14 | 25767.12 | 25561.99 | 25067.34 | 24968.82 | 25113.33 | 25023.13 | 24977.85 | 24710.75 | 24177.09 | 23641.58 | 23597.07 | 23555.27 | 23408.48 | 23299.45 | 23390.06 | 23337.90 | 23250.59 | 23110.63 | 22952.47 | 22834.64 | 22663.02 |
# Use kable() from the knitr package to render the table.
# Here, plot a line graph showing the trend of DALY burden for the chosen countries over time. You can use ggplot2 to create this plot. Each country's line should be a different color.
# NOTE: Use your long 'mini' data frame for plotting, not the wide data used for the table.
data_ncd_linechart <-data_ncd_mini %>%
ggplot(aes(x = year, y = daly, color = country)) +
geom_line(size = 1.2) +
geom_point(size = 2) +
labs(
title = "DALYs Over Time",
x = "Year",
y = "Disability-Adjusted Life Years (DALY)",
color = "Country"
) +
theme_minimal()
## Warning: Using `size` aesthetic for lines was deprecated in ggplot2 3.4.0.
## ℹ Please use `linewidth` instead.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.
ggplotly(data_ncd_linechart)
Provide a brief analysis based on the data presented in the table and chart. Highlight any significant findings or patterns. About 3 sentences.
Between 1990 and 2019, all three countries saw overall declines in non-communicable disease DALYs, with Brazil showing the most consistent year-on-year reduction from about 26 800 to just over 20 000.
Brunei’s DALYs fell from roughly 29 500 to 22 700, though there was a mid-2000s plateau before renewed improvement.
In contrast, Botswana experienced a pronounced rise in DALYs—peaking near 32 000 in the mid-2000s—before reversing course to end at approximately 25 600, mirroring regional gains in disease control but highlighting a later start.